home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / program / swmp141.zip / C_SDK.ZIP / EXAMPLE2.C < prev    next >
Text File  |  1995-12-12  |  3KB  |  101 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4. #include "modplay.inc"
  5.  
  6. unsigned int _stklen  = 0x1000;         /* set stack size to 4kB */
  7. unsigned int _heaplen = 0x0000;         /* no heap required      */
  8.  
  9. unsigned char Key, Main_Volume;
  10. unsigned int  Cursor_Shape;
  11.  
  12. void Init_Cursor(void)
  13. {
  14.  asm {
  15.   mov     ah,3
  16.   xor     bh,bh
  17.   int     10h
  18.   mov     [Cursor_Shape],cx
  19.   mov     ah,1
  20.   mov     cx,2020h
  21.   int     10h
  22.  }
  23. }
  24.  
  25. void Restore_Cursor(void)
  26. {
  27.  asm {
  28.   mov     ah,1
  29.   mov     cx,[Cursor_Shape]
  30.   int     10h
  31.  }
  32. }
  33.  
  34. void Update_Screen(void)
  35. {
  36.  unsigned int i,j;
  37.  unsigned char Bar[32];
  38.  unsigned int SongPos;
  39.  
  40.  gotoxy(1,7);
  41.  Mod_Peak();
  42.  for(i=0; i<Channels; i++) {
  43.   strcpy(Bar,"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░");
  44.   if (Peak[i]>1) for(j=0; j<(Peak[i]>>1); j++) Bar[j]='▓';
  45.   gotoxy(2,4+i); cprintf("%s", Bar);
  46.  }
  47.  SongPos=Mod_Position();
  48.  gotoxy(3,6+Channels); cprintf("Playing pattern #%d, line #%d  ", SongPos>>8, SongPos&0x00ff);
  49.  gotoxy(62,wherey()); cprintf("Main volume: %3d%%", div(Main_Volume*100,64));
  50. }
  51.  
  52. void main(void)
  53. {
  54.  Mod_Init(Detection,0,0,0);
  55.  if (Soundcard!=0) {
  56.   Mod_Load("DONTYOU.MOD");
  57.   if (Channels!=0) {
  58.    Init_Cursor();
  59.    Main_Volume=58;
  60.    Mod_Volume(Main_Volume);
  61.    Mod_Play(0);
  62.    textcolor(WHITE); textbackground(BLACK);
  63.    clrscr();
  64.    textbackground(BLUE); gotoxy(1,1); clreol();
  65.    gotoxy(22,1); cprintf("SOUND WIZARDS MODULE PLAYER 'C' DEMO");
  66.    gotoxy(1,6+Channels); clreol();
  67.    textbackground(BLACK);
  68.    gotoxy(36,1+Channels); cprintf("Press       up,down:     to adjust volume  ");
  69.    gotoxy(36,2+Channels); cprintf("            left,right:  to change position");
  70.    gotoxy(36,3+Channels); cprintf("or escape to quit this little program......");
  71.    textbackground(BLUE);
  72.    do {
  73.     Update_Screen();
  74.     Key=' ';
  75.     if (kbhit()) Key=getch();
  76.     if (Key==0) {       /* only allow function keys */
  77.      Key=getch();
  78.      switch(Key) {
  79.       case 0x48: if (Main_Volume<64) {
  80.                   Main_Volume+=2;
  81.                   Mod_Volume(Main_Volume);
  82.                  }
  83.                  break;
  84.       case 0x50: if (Main_Volume>0) {
  85.                   Main_Volume-=2;
  86.                   Mod_Volume(Main_Volume);
  87.                  }
  88.                  break;
  89.       case 0x4d: Mod_Forward();
  90.                  break;
  91.       case 0x4b: Mod_Rewind();
  92.                  break;
  93.      }
  94.     }
  95.    } while((Mod_Status()!=0) && (Key!=27));
  96.    gotoxy(1,9+Channels);
  97.    Restore_Cursor();
  98.   } else printf("\nCould not load song DONTYOU.MOD...\n");
  99.  } else printf("\nCould not initialize hardware...");
  100. }
  101.